sizerequest: Make size groups "work"
authorTimm Bäder <mail@baedert.org>
Sat, 6 May 2017 12:05:30 +0000 (14:05 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 20 Jul 2017 01:27:11 +0000 (21:27 -0400)
We have to query the css margin/border/padding values for all widgets
in the size group.

gtk/gtksizerequest.c

index 9648f22c7791c711239efd3b4fa35665aeec7734..5b54ea386110283f4b016a8b7cb6a45bc7df0016 100644 (file)
@@ -479,17 +479,30 @@ gtk_widget_measure (GtkWidget        *widget,
       GtkWidget *tmp_widget = key;
       gint min_dimension, nat_dimension;
 
+      style = gtk_css_node_get_style (gtk_widget_get_css_node (tmp_widget));
+      get_box_margin (style, &margin);
+      get_box_border (style, &border);
+      get_box_padding (style, &padding);
+
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
+        {
+          css_extra_size = margin.left + margin.right + border.left + border.right + padding.left + padding.right;
+          css_min_size = get_number (style, GTK_CSS_PROPERTY_MIN_WIDTH);
+        }
+      else
+        {
+          css_extra_size = margin.top + margin.bottom + border.top + border.bottom + padding.top + padding.bottom;
+          css_min_size = get_number (style, GTK_CSS_PROPERTY_MIN_HEIGHT);
+        }
+
       gtk_widget_query_size_for_orientation (tmp_widget, orientation, for_size, &min_dimension, &nat_dimension, NULL, NULL);
 
-      min_result = MAX (min_result, min_dimension);
-      nat_result = MAX (nat_result, nat_dimension);
+      min_result = MAX (min_result, MAX (min_dimension, css_min_size) + css_extra_size);
+      nat_result = MAX (nat_result, MAX (nat_dimension, css_min_size) + css_extra_size);
     }
 
   g_hash_table_destroy (widgets);
 
-  /* TODO: Since we query the content sizes for all the widget in the size group, we need to also
-   *       query all the widget sizes for all of them and MAX that? */
-
   /* Baselines make no sense with sizegroups really */
   if (minimum_baseline)
     *minimum_baseline = -1;
@@ -498,10 +511,10 @@ gtk_widget_measure (GtkWidget        *widget,
     *natural_baseline = -1;
 
   if (minimum)
-    *minimum = min_result + css_extra_size;
+    *minimum = min_result;
 
   if (natural)
-    *natural = nat_result + css_extra_size;
+    *natural = nat_result;
 }
 
 /**